
import redis
import sys

class icanSeqTaskPost():

    def __init__(self, host='localhost', port=6379):
        pool = redis.ConnectionPool(host=host, port=port, db=0)
        self.r = redis.StrictRedis(connection_pool=pool)


    def run(self,command):


        p = self.r.pubsub()
        p.subscribe('SubcribeQueue')
        self.r.lpush('PendingQueue', command)
        for item in p.listen():
            try:
                print item
                data = eval(item['data'])
                print data[1]
                if data[1] == command:
                    break ;
            except Exception, exception:
                print exception

if __name__ == '__main__':
    inst = icanSeqTaskPost()
    inst.run(sys.argv[1])